<?php

declare(strict_types=1);

namespace Modules\Production\Models;

use Modules\Base\Models\Material;
use Catch\Base\CatchModel as Model;

/**
 * @property $id
 * @property $pick_order_id
 * @property $pick_detail_id
 * @property $material_no
 * @property $lot_num
 * @property $qty
 * @property $creator_id
 * @property $created_at
 * @property $updated_at
 * @property $deleted_at
*/
class PickOrderDetailSplit extends Model
{

    protected $table = 'pick_order_detail_split';

    protected $fillable = [ 'id', 'pick_order_id', 'pick_detail_id', 'material_no', 'lot_num', 'qty', 'creator_id', 'created_at', 'updated_at', 'deleted_at' ];

    /**
     * @var array
     */
    protected array $fields = ['id','pick_order_id','pick_detail_id','material_no','lot_num','qty','created_at','updated_at'];

    /**
     * @var array
     */
    protected array $form = ['id','pick_order_id','pick_detail_id','material_no','lot_num','qty','created_at','updated_at'];

    /**
     * @var array
     */
    public array $searchable = [

    ];

    /**
     * 时间格式化
     * @param $date
     * @return mixed
     */
    protected function serializeDate($date)
    {
        return $date->format('Y-m-d H:i');
    }

    /**
     * 关联领料明细信息
     * @return mixed
     */
    public function pickdetail(){
        return $this->hasOne(PickOrderDetail::class,'id','pick_detail_id');
    }

    /**
     * 关联领料单
     */
    public function order(){
        return $this->belongsTo(PickOrder::class,'pick_order_id');
    }

    /**
     * 关联产品信息
     * @return mixed
     */
    public function material(){
        return $this->hasOne(Material::class,'fnumber','material_no');
    }


}
